/* 
 * File:   TestSceneBuilder.h
 * Author: brady
 *
 * Created on June 27, 2011, 6:34 PM
 */

#ifndef TESTSCENEBUILDER_H
#define	TESTSCENEBUILDER_H
#include <shapes/Sphere.h>
#include <shapes/Shape.h>
#include <parsing/SceneBuilder.h>
#include <shaders/DielectricShader.h>
#include <acceleration/IntersectionStructure.h>
#include <acceleration/ShapeList.h>
#include <core/Camera.h>
#include <shapes/Triangle.h>
#include <shapes/Sphere.h>
#include <shaders/SimpleShader.h>
#include <shaders/LambertianShader.h>
#include <shaders/BlinnphongShader.h>
#include <shaders/DielectricShader.h>
#include <textures/FlatTexture.h>
#include <core/Vertex.h>

using namespace std;
class TestSceneBuilder : public SceneBuilder {
public:
    TestSceneBuilder();
    TestSceneBuilder(const TestSceneBuilder& orig);
    virtual ~TestSceneBuilder();
    Scene* buildSceneFromFile(const char* inputFile){
        Scene* scene = new Scene();

        Camera camera = Camera();
        scene->camera = camera;
        scene->camera.origin = Vector3D(-2.0, 6.0, 6.0);
        scene->camera.gaze = Vector3D(0.25, -0.55, -1.0).normalize();
        scene->camera.focalLength = 2.0;
        scene->camera.planeWidth = 1.0;
        scene->camera.buildBasis();

        Sphere* sphere = new Sphere(Vector3D(0 , 1.0, -4), 1.0);
        Texture* sphereTexture = new FlatTexture(Vector3D(.6, 0.0, .6));
        Shader* sphereShader = new BlinnphongShader(Vector3D(1,1,1), 50, 0.0);
        sphere->texture = sphereTexture;
        Texture* triangleTexture = new FlatTexture(Vector3D(0.2, 0.7, 0.2));
        Shader* triShader = new BlinnphongShader(Vector3D(1,1,1), 50, 0.4);
        sphere->setShader(sphereShader);

        Triangle* triangle = new Triangle(new Vertex(Vector3D(0, 0, -10)),
                                          new Vertex(Vector3D(-10, 0, 0)),
                                          new Vertex(Vector3D(10, 0, 0)));
        triangle->setShader(triShader);
        triangle->texture = triangleTexture;

        Sphere* dielsphere = new Sphere(Vector3D(1.5, 0.8, -2), 0.8);
        DielectricShader* diShader = new DielectricShader();
        dielsphere->texture = new FlatTexture(Vector3D(1,1,1));
        diShader->setReflectivity(1);
        diShader->setRefractiveIndex(1.8);
        diShader->setTransparency(1);
        diShader->setSpecularColor(Vector3D(1,1,1));
        diShader->setPhongExponent(64);
        dielsphere->setShader(diShader);


        
        scene->intersectionStructure = new ShapeList();
        scene->intersectionStructure->addShape(sphere);
        scene->intersectionStructure->addShape(triangle);
        scene->intersectionStructure->addShape(dielsphere);
        scene->intersectionStructure->finalize();
        scene->backgroundColor = Vector3D(0.0,0.1,0.3);
        scene->ambientColor = Vector3D(0.05, 0.05, 0.05);

        scene->lights = vector<Light*>();
        scene->lights.push_back(new PointLight(Vector3D(1.0, 7.0, 5.0), Vector3D(0.7,0.7,0.7)));
        scene->lights.push_back(new PointLight(Vector3D(-7.0, 4.0, 2.0), Vector3D(0.4,0.4,0.4)));

        return scene;
    }

private:

};

#endif	/* TESTSCENEBUILDER_H */

